--编写者：alt
--功能介绍：重定向事件的目标函数
--使用方法：直接粘贴 修改actionlist

--重定向事件的目标函数
local eventlist = {
	["death"] = function(inst, data, ...)
		if --[[ TUNING.HERTA_AUTHORMODE and  ]] inst.herta_curio_4_num and inst.herta_curio_4_num > 0 then
			if inst.sleepingbag ~= nil and (inst.sg:HasStateTag("bedroll") or inst.sg:HasStateTag("tent")) then
				inst.sleepingbag.components.sleepingbag:DoWakeUp()
				inst.sleepingbag = nil
			end
			inst.sg:GoToState("herta_death")
			return --return true需要注意返回值 决定hook的效果
		end
	end,
}
AddStategraphPostInit("wilson", function(self)
	for k, v in pairs(eventlist) do
		local oldhandlers = self.events[k].fn
		self.events[k].fn = function(inst, data, ...)
			local newresult = v(inst, data, ...)
			if newresult then
				return newresult
			end
			local oldresult = oldhandlers(inst, data, ...)
			return oldresult
		end
	end
end)
--客户端
local eventlist_client = {
	--[[["death"] = function(inst, data, ...)
		if inst.sleepingbag ~= nil and (inst.sg:HasStateTag("bedroll") or inst.sg:HasStateTag("tent")) then
			inst.sleepingbag.components.sleepingbag:DoWakeUp()
			inst.sleepingbag = nil
		end
		inst.sg:GoToState("herta_death")
		return --return true需要注意返回值 决定hook的效果
	end,]]
}
AddStategraphPostInit("wilson", function(self)
	for k, v in pairs(eventlist_client) do
		local oldhandlers = self.events[k].fn
		self.events[k].fn = function(inst, data, ...)
			local newresult = v(inst, data, ...)
			if newresult then
				return newresult
			end
			local oldresult = oldhandlers(inst, data, ...)
			return oldresult
		end
	end
end)
